<?php
loadTemp("admin/models/class/classheader.php");
?>
<script type="text/javascript">
$(document).ready(function(){
	loadAdminTopItem();
	activeAdminTopItem("s_c_listclass");
});
</script>
<?php checkAdminPermission("admin.class.list_class","admin.class.*");?>
<!-- Start -->
<script type="text/javascript">
$(document).ready(function(){
	$("#yearTemple").hide();
	$("#class_item_temple").hide();
	ajaxRequest("","admin.php?mod=class&ajax=true&op=listClasses",s_listclass_onSuccess,s_listclass_onError,"admin_di");
});
function s_listclass_onSuccess(data){
	s_listclass_operatedone(data.code,data.message,data.data);

}
function s_listclass_onError(data){
	console.log(data);
	s_listclass_operatedone(-101,"服务器返回了未知的数据，请上报管理员",data.responseText);
}
function s_listclass_operatedone(id,message,data){
	if(id==-101){
		showMessage("s_listclass_message",-101,message+"<br><br><pre>"+data+"</pre>");
		return;
	}
	if(id!=0&&id!=3){
		showMessage("s_listclass_message",id,message);
	}
	if(id==0){
		showMessage("s_listclass_message",id,message);
	}
	if(data.op=="listAllClasses"){
		$.each(data.data,function(k,v){
			loadYear(k,v);
		});
	}
}
function loadYear(year,data){
	console.log(year);
	var div = $("#yearTemple").clone();
	div.attr("id","");
	div.show();
	div.find(".header").html(year+"级");
	$.each(data,function(k,v){
		div.find(".list").append(loadClass(v));
	});
	$(".Classeslist").append(div);
}
function loadClass(v){
	var $tmp = $("#class_item_temple").clone();
	$tmp.attr("id","");
	$tmp.show();
	console.log($tmp.find(".s_classid_id"));
	$tmp.find(".s_state").html(v.enable==1?"未毕业":"已毕业");
	$tmp.find(".s_classname").html(v.displayname);
	$tmp.find(".s_classid").html(v.classid);
	$tmp.find(".s_introduce").html("班级叙述："+v.description);
	$tmp.find(".s_classnum").html("班级人数："+v.stunum);
	return $tmp;
}
</script>
<div class="s_admin_in_container">
	<h2 class="ui dividing header">班级列表</h2>
	<div class="ui message">
		<div class="header">小提示</div>
		<ul class="list">
			<li>这里是班级列表</li>
			<li>你可以在这里查看班级信息</li>
		</ul>
	</div>
	<div class="ui message hidden" id="s_listclass_message"></div>
	<div class="Classeslist"></div>
</div>
<div id="yearTemple" style="padding-bottom: 0.5cm">
	<h4 class="ui dividing header"></h4>
	<div class="ui middle relaxed aligned divided list"></div>
</div>
<div class="item" id="class_item_temple">
	<div class="right floated content">
		<span class="lm_item s_state"></span>
		<span class="lm_item s_classnum"></span>
	</div>
	<div class="content">
		<div class="header">
			<span class="s_classname"></span>
			(
			<span class="s_classid"></span>
			)
		</div>
		<div class="extra text s_introduce"></div>
	</div>
</div>
